class Solution {
public:
    ListNode* swapPairs(ListNode* head) {
        if (head == nullptr || head->next == nullptr)
        return head;
        
        ListNode* tmp = head->next->next;
        ListNode* ret = head->next;
        ret->next = head;
        head->next = swapPairs(tmp);
        
        return ret;
    }
};